﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using ATW.MT.CommonClass;
using System.Text;
using System.Data;
using ATW.MT.BUS;

namespace ATW.MT.SellManage
{
    public partial class CustomerManage : CommonPage
    {
        bus_T_appuser user = new bus_T_appuser();
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                getCurrencyList();
                BindData();
            }
        }
        private void BindData()
        {
            try
            {
                string name = txtName.Value.Trim();
                if (common.filterChar(name))
                {
                    DataTable dt = user.UserPagerQuery(name, "4", AspNetPager1.CurrentPageIndex, AspNetPager1.PageSize);
                    if (dt != null && dt.Rows.Count > 0)
                    {
                        AspNetPager1.RecordCount = Convert.ToInt32(dt.Rows[0]["totalpagesize"]);
                    }
                    else
                    {
                        AspNetPager1.RecordCount = 0;
                    }
                    rpList.DataSource = dt;
                    rpList.DataBind();
                }
            }
            catch (Exception ex)
            {

            }
        }
        private void getCurrencyList()
        {
            try
            {
                ddlCurrency.Items.Clear();
                DataTable dt = user.CurrencyQuery();
                if (dt != null && dt.Rows.Count > 0)
                {
                    for (int i = 0; i < dt.Rows.Count; i++)
                    {
                        ddlCurrency.Items.Add(new ListItem(dt.Rows[i]["dcname"].ToString(), dt.Rows[i]["dcid"].ToString()));
                    }
                }
            }
            catch (Exception ex)
            {

            }
        }
        protected void btnSearch_Click(object sender, EventArgs e)
        {
            AspNetPager1.CurrentPageIndex = 1;
            BindData();
        }
        protected void AspNetPager1_pageChanged(object sender, EventArgs e)
        {//分页
            BindData();
        }
        private void Tips(string s)
        {
            StringBuilder strScript = new StringBuilder();
            strScript.Append(@"<script language=javascript>
                var divTips=new jSharp.popUpDiv('divMsg');
                document.getElementById('msgContent').innerHTML='" + s + @"';
                divTips.Show();
                var t=setTimeout(function(){
                    divTips.Close();
                    clearTimeout(t);
                },1000);
            </script>");
            this.ClientScript.RegisterStartupScript(this.GetType(), "tips", strScript.ToString());
        }//提示
    }
}